JavaLoader and classpath behavior different on Adobe CF 8/9 and Railo 3 with interface classes

262 views
Skip to first unread message

TomdeMan

unread,
Mar 4, 2010, 5:57:26 PM3/4/10
to javaloader-dev
I am working with the YUICompressor Java library, and noticed some odd
behavior. Placing the yuicompressor-2.4.2.jar into the CF classpath
and using createObject() throws the following error:

An exception occurred when instantiating a Java object. The class must
not be an interface or an abstract class. Error: ''.

The same code, using javaloader to create() an object of the same
class runs successfully on CF 8 and CF 9.
Running it on Railo 3 produces the same error as the CF classpath.

The class in question is the ErrorReporter. The error is thrown on the
init of the JavaScriptCompressor, the reporter is created successfully
prior to that. (Even though it is just an interface, and no init
method is specified)

inputStream =
createObject('java','java.io.StringReader').init(inputString);
reporter = create('org.mozilla.javascript.ErrorReporter');
JavaScriptCompressor =
create('com.yahoo.platform.yui.compressor.JavaScriptCompressor').init(inputStream,reporter);

org.mozilla.javascript.ErrorReporter' is an interface.

The fact that it works at all was surprising too me.

I would really like to get to the bottom of this and be able to offer
a solution that runs on all platforms.

I am no expert with Java or the underlying CF class loader system and
would appreciate any feedback.

The YUICompressor jar and java src can be found at:
http://yuilibrary.com/downloads/yuicompressor/yuicompressor-2.4.2.zip

Mark Mandel

unread,
Mar 4, 2010, 6:00:16 PM3/4/10
to javaloa...@googlegroups.com
Being lazy - where can I find the JavaDoc for YUICompressor?

Mark
--
E: mark....@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

Hands-on ColdFusion ORM Training @ cf.Objective() 2010
www.ColdFusionOrmTraining.com/

TomdeMan

unread,
Mar 4, 2010, 6:10:01 PM3/4/10
to javaloader-dev
I never found them online, I went off the src files that were included
with the jar in the download package.

> E: mark.man...@gmail.com

Matt Gersting

unread,
Mar 4, 2010, 6:12:51 PM3/4/10
to javaloa...@googlegroups.com

Mark Mandel

unread,
Mar 4, 2010, 6:20:13 PM3/4/10
to javaloa...@googlegroups.com
Thanks for that Matt - but I'm looking for the JavaDoc documentation.

Tom - first thing I would do is generate the JavaDoc documentation, so you can browse how the library is implemented.  Browsing source for this is tough.

Secondly, if ErrorReporter is an interface - yes, you can't create one. It's an interface.

ColdFusion does have a 'feature' is if you request an interface it will create an implementation for you that does nothing (i.e. not very useful).  Railo is probably giving you back the more 'correct' error.

If you do a javadoc of the library, you will be able to see what implements the ErrorReporter interface - I would expect that there is a default implementation with the library, and use that.

Mark
--
E: mark....@gmail.com

Tom de Manincor

unread,
Mar 4, 2010, 9:04:26 PM3/4/10
to javaloader-dev
I can understand Railo's error being correct if it does not have the
feature that CF does for creating that skeleton interface object.
But what I can't understand is why it would not work on CF without
javaloader???

To me it seemed like a conflict of pre-loaded libraries in the CF
classpath.
I have verified another instance of
org.mozilla.javascript.ErrorReporter in one of the other jars.
That is why I assumed it worked with JavaLoader.

But not working on Railo with JavaLoader made me wonder if Railo and
JavaLoader have something different going on with respect to loading
the existing coldfusion libraries.

Which led me to try creating the same implementation the YUI java
source used to create the object.
I created a java class of the same type but different package.
Created the jar and threw it in the cf classpath.
Changed my code to create one of my new classes and passed that in,
and got the same error, about it being an interface or an abstract
class.

My next move would be to repackage the YUICompressor jar, but before I
do that the big question to me is...

How did JavaLoader get it to work? What is it doing? Got to be a way
to mimic it?


On Mar 5, 12:20 am, Mark Mandel <mark.man...@gmail.com> wrote:
> Thanks for that Matt - but I'm looking for the JavaDoc documentation.
>
> Tom - first thing I would do is generate the JavaDoc documentation, so you
> can browse how the library is implemented.  Browsing source for this is
> tough.
>
> Secondly, if ErrorReporter is an interface - yes, you can't create one. It's
> an interface.
>
> ColdFusion does have a 'feature' is if you request an interface it will
> create an implementation for you that does nothing (i.e. not very useful).
> Railo is probably giving you back the more 'correct' error.
>
> If you do a javadoc of the library, you will be able to see what implements
> the ErrorReporter interface - I would expect that there is a default
> implementation with the library, and use that.
>
> Mark
>
>
>
> On Fri, Mar 5, 2010 at 10:12 AM, Matt Gersting <mgerst...@gmail.com> wrote:
> > Is this what you're looking for, Mark?
>

> >http://github.com/yui/yuicompressor/blob/0e290b8e05392f19bccc2f7d5247...

Mark Mandel

unread,
Mar 4, 2010, 9:13:50 PM3/4/10
to javaloa...@googlegroups.com
Tom,


On Fri, Mar 5, 2010 at 1:04 PM, Tom de Manincor <tom.dem...@gmail.com> wrote:
I can understand Railo's error being correct if it does not have the
feature that CF does for creating that skeleton interface object.
But what I can't understand is why it would not work on CF without
javaloader???

Why does it matter? If you do it correctly (and follow the ideas I suggested below, you can get this working no problem).

I think you're making this overly complicated.

Mark
--
E: mark....@gmail.com

Tom de Manincor

unread,
Mar 8, 2010, 7:40:05 PM3/8/10
to javaloader-dev
I've tried all kinds of stuff to get this to work with the CF
classpath with little success, just one error after another coming
from classes in the org.mozilla.javascript package.

So I am taking a break with the CF classpath issue and focus on Railo
with JavaLoader.

The same code that works in CF with JavaLoader produces the following
error in railo:

No matching Constructor for
com.yahoo.platform.yui.compressor.JavaScriptCompressor(java.io.StringReader,
coldfusion.runtime.java.JavaProxy) found

There is nothing in the stack trace indicating what if anything
happened with the java code behind the scenes.

On Mar 5, 3:13 am, Mark Mandel <mark.man...@gmail.com> wrote:
> Tom,
>

> On Fri, Mar 5, 2010 at 1:04 PM, Tom de Manincor <tom.demanin...@gmail.com>wrote:
>
> > I can understand Railo's error being correct if it does not have the
> > feature that CF does for creating that skeleton interface object.
> > But what I can't understand is why it would not work on CF without
> > javaloader???
>
> Why does it matter? If you do it correctly (and follow the ideas I suggested
> below, you can get this working no problem).
>
> I think you're making this overly complicated.
>
> Mark
> --

> E: mark.man...@gmail.com

Mark Mandel

unread,
Mar 8, 2010, 7:44:07 PM3/8/10
to javaloa...@googlegroups.com
That looks like a bug in Railo's Java reflection and invocation implementation.

Mark
--
E: mark....@gmail.com
Reply all
Reply to author
Forward
0 new messages